/**
* ConvertAcquirerId.java
*
* Created on   : Jan 10, 2013
* Target OS    : Java VM 1.6 
* CVS revision : $Revision: 1.0 $ 
*
* ------------------------------
* CHANGE REVISION
* ------------------------------
* DATE           AUTHOR      	   REVISION    	
* Jan 10, 2013   PMTuan 1.0    First release.
* -------------------------------
* CLASS DESCRIPTION
* -------------------------------
*
*/
package com.cps.match.xmlparser;

import com.cps.match.sdo.AcquirerId;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

/**
 * @author pmtuan
 *
 */
public class ConvertAcquirerId implements Converter {

	/* (non-Javadoc)
	 * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext)
	 */
	public void marshal(Object source, HierarchicalStreamWriter writer,
			MarshallingContext context) {
		AcquirerId acquirerId = (AcquirerId) source;		
		boolean bAddNode = (acquirerId!= null) ;
		if (bAddNode) {
			writer.setValue(acquirerId.getId().toString()) ;
//			writer.endNode();
		}
		
	}

	/* (non-Javadoc)
	 * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.UnmarshallingContext)
	 */
	public Object unmarshal(HierarchicalStreamReader arg0,
			UnmarshallingContext arg1) {
		AcquirerId acquirerId = new AcquirerId();
		arg0.moveDown();
		arg0.moveUp();
		return acquirerId;
	}

	@SuppressWarnings("rawtypes")
	public boolean canConvert(Class arg0) {
		return arg0.equals(AcquirerId.class);
	}
}